package org.pay.settlement.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.pay.core.common.util.DateUtil;
import org.pay.core.common.util.MyLog;
import org.pay.settlement.service.MchSettService;

import java.util.Date;

/**
 * @author: yangshancheng
 * @date: 17/12/3
 * @description:
 */
@Component
public class SettScheduled {

    @Autowired
    private MchSettService mchSettService;

    private static final MyLog _log = MyLog.getLog(SettScheduled.class);

    //@Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次
    @Scheduled(cron="0 5 0 ? * *")  // 每日零点零五执行
    public void settDailyCollectTask() {
        //String collDate = DateUtils.getCurrentTimeStr("yyyy-MM-dd");
        // 得到昨天日期
        Date billDate = DateUtil.addDay(new Date(), -1);
        String collDate = DateUtil.date2Str(billDate, DateUtil.FORMAT_YYYY_MM_DD);
        _log.info("执行({})待结算汇总数据,开始...", collDate);
        mchSettService.buildSettDailyCollect(collDate);
        _log.info("执行({})待结算汇总数据,结束。", collDate);
    }

}
